//////////////////////////////////////////////////////////////////////////////////////////////////
//
//	File: kernelTask.h
//
//	Original author: Tomas Sandnes / NITH / 2009
//	Changed by:	---
//
//	Description: Simple interface that lists the mandatory functionality for our kernel tasks.
//
//	Special notes: ---
//
//////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef KERNEL_TASK_H  // Inclusion guard.
#define KERNEL_TASK_H



// I N C L U D E S
// ===============

#include "Logger.h"



// I N T E R F A C E   D E C L A R A T I O N
// =========================================

class IKernelTask
{
public:
	IKernelTask(std::string logId, long priorityP = 5000): logger(logId){kill = false; priority = priorityP; logger << INFO << "Parent constructor done.";}
	virtual ~IKernelTask(){logger << INFO << "Destructor done.";}

	// Retrieves the priority value of this task (lower value = higher priority).
	virtual long GetPriority(){return priority;}

	// Returns true if task should be stopped, and removed from any task list.
	virtual bool CanKill(){return kill;}

	// Flags task for removal.
	virtual void FlagForKill(){kill = true;}

	// Pure virtual function. Should contain initializing stuff to be done when a task is added to the kernel system.
	virtual bool Start() = 0;

	// Pure virtual function. Should contain cleanup stuff to be done when a task is removed from the kernel system.
	virtual void Stop() = 0;

	// Pure virtual function. Should contain repeating stuff to be done repeatedly in the kernel.
	virtual void Update() = 0;

	// Should be overloaded if we want to do special stuff on a task pause.
	virtual void Suspend(){}

	// Should be overloaded if we want to do special stuff returning from a task pause.
	virtual void Resume(){}

protected:
	Logger logger;

	bool kill;  // When true, task will be stopped and then removed by the kernel system.
	long priority;  // Lower number = higher priority!
};

#endif  // END Inclusion guard.
